<?php
/* this could be done in an iframe with a meta refresh tag and a transition tag.
the ideal aspect of that would be the new ads each time
*/

$page = -1;
if (isset($_REQUEST['page']))
	$page = $_REQUEST['page'];

if ($page == 0)
	$page = -1;

$qtest = "Post Rate";
if (isset($_REQUEST['qtest']))
	$qtest = $_REQUEST['qtest'];
	
	include_once ("dateformat.php");

?>



<?php
	$access_token = $_SESSION['access_token'];

/* Create a TwitterOauth object with consumer/user tokens. */
	$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

	//need to get followers
	$jsonDecode = $connection->get('statuses/followers', array('cursor' => $page));

	include_once("qwollow/".$qtest.".php");

//print_r($jsonDecode);

?>
<table width="100%" id="rowOn">
<tr>
<td colspan="2">
<h2><?php echo $qwollowname; ?></h2>
<div>Description:<br /> <?php echo $qwollowdescription; ?></div>
<br />
<div>Created By: <br /><a href="<?php echo $qwollowauthorurl; ?>"><?php echo $qwollowauthor; ?></a></div>
<br />
</td>
</tr>
</table>

<span id="timelinetitle"><?php echo $access_token['screen_name']; ?></span>&nbsp;&nbsp;<span id="timelinecount"><?php echo count($jsonDecode->users); ?> followers</span>
<hr id="simplehr" />
<table id="timelinetable" cellspacing="0" cellpadding="5">
<?php

	$innocentcount = 0;
	foreach ((array)$jsonDecode->users as $timelineEntry)
	{

		$result = qwollowfy($timelineEntry);

		//result is degree of result. 
		//1. 0-10 is really failed
		//2. 11-25 is next worse
		//3. 26-50 is next
		//4. 51-75 is warning
		//5. 76-100 is next warning
		//6. 100+ is no problems.

		$rowid = "qw6";

		if ($result < 10)
		{
			$rowid = "qw1";
		}
		else if ($result < 25)
		{
			$rowid = "qw2";
		}
		else if ($result < 50)
		{
			$rowid = "qw3";
		}
		else if ($result < 75)
		{
			$rowid = "qw4";
		}
		else if ($result < 100)
		{
			$rowid = "qw5";
		}	
		else if ($result > 99)
		{
			$innocentcount++;
			continue;
		}	
?>
	<tr id="<?php echo $rowid; ?>">
	<td valign="top">
		<a class="dock-item2" href="http://www.twitter.com/<?php echo $timelineEntry->screen_name; ?>"><img src="<?php echo $timelineEntry->profile_image_url; ?>" alt="(~.~)" title="<?php echo $timelineEntry->description;?>" width="48" height="48" border="0" /></a><form action="index.php" method="GET"><input type="hidden" name="start" value="prune" /><input type="hidden" name="tuser" value="<?php echo $timelineEntry->id; ?>" /><input type="hidden" name="tusername" value="<?php echo $timelineEntry->screen_name; ?>" /><input type="image" src="images/pruneicon.gif" alt="Prune <?php echo $timelineEntry->screen_name; ?>" title = "Prune <?php echo $timelineEntry->screen_name; ?>" value="p" /><a href="_action.php?action=unfollow&start=qwollow&tuser=<?php echo $timelineEntry->id; ?>&qtest=<?php echo urlencode($qtest); ?>"><img src="images/unfollow.gif" border="0" alt="Block <?php echo $timelineEntry->screen_name; ?>." title="Block <?php echo $timelineEntry->screen_name; ?>." /></a><a href="_action.php?action=reportspam&start=qwollow&tuser=<?php echo $timelineEntry->id; ?>&qtest=<?php echo urlencode($qtest); ?>"><img src="images/reportspam.gif" border="0" alt="Flag <?php echo $timelineEntry->screen_name; ?> for spam." title="Flag <?php echo $timelineEntry->screen_name; ?> for spam." /></a></form>
	</td>
	<td valign="top" colspan="3"><a href="http://www.twitter.com/<?php echo $timelineEntry->screen_name; ?>"><?php echo $timelineEntry->screen_name; ?></a><br /> <?php echo $timelineEntry->description; ?><br />
	<strong>Followers: </strong><?php echo $timelineEntry->followers_count; ?><br />
	<strong>Following: </strong><?php echo $timelineEntry->friends_count; ?><br />
	<strong>Tweets: </strong><?php echo $timelineEntry->statuses_count; ?><br />
	<strong>Created: </strong><?php echo formatDate($timelineEntry->created_at); ?>
	 </td>
	
	</tr>
<?php
	
	}
	
?> 
	<tr>
		<td colspan="4">
			<div id="entrysource"><?php echo $innocentcount; ?> followers pass this test.</div>
		</td>
	</tr>

	<tr>
		<td>
			
		</td>
		<td colspan="3">
			<form action="index.php" method="GET">
			<input type="hidden" name="start" value="qwollow" />
			<input type="hidden" name="qtest" value="<?php echo $qtest; ?>" />
			<input type="hidden" name="page" value="<?php echo $jsonDecode->previous_cursor; ?>" />
			<input type="submit" value="back" id="pagebutton" />
			</form>			
			<form action="index.php" method="GET">
			<input type="hidden" name="start" value="qwollow" />
			<input type="hidden" name="qtest" value="<?php echo $qtest; ?>" />
			<input type="hidden" name="page" value="<?php echo $jsonDecode->next_cursor; ?>" />
			<input type="submit" value="next" id="pagebutton" />
			</form>
		</td>
	</tr>
</table>
